import Cookies from 'js-cookie'

const TokenKey = 'huapuauth'

export function getToken() {
  // return Cookies.get(TokenKey)
  const t = sessionStorage.getItem(TokenKey);
  return t || localStorage.getItem(TokenKey);
}

export function setToken(token, isSave = false) {
  isSave ? localStorage.setItem(TokenKey, token) : sessionStorage.setItem(TokenKey, token);
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  sessionStorage.removeItem(TokenKey);
  localStorage.removeItem(TokenKey);
  return Cookies.remove(TokenKey);
}
